module bin2bcd (
		input [6:0] bin,
		output reg [3:0] ones, tens
		);

   integer 			 i;
   always @(bin)
     begin
	ones = 4'b0000;
	tens = 4'b0000;

	for (i = 6; i >= 0; i = i-1)
	  begin
	     if (tens >= 5)
	       tens = tens + 3;
	     if (ones >= 5)
	       ones = ones + 3;

	     tens = tens << 1;
	     tens[0] = ones[3];
	     ones = ones << 1;
	     ones[0] = bin[i];
	  end // for (i = 7; i >= 0; i = i-1)
     end // always @ (bin)
endmodule // bin2bcd	
		
